<?php
class Zendvn_Validate{
	
	private $_validatorObj;
	
	private $_configFile;
	
	public function __construct($options = null){
		$this->_validatorObj = new Zend_Validate();
		$this->_configFile = new Zendvn_Controller_Config(array('module'=>$options['module'],
													 'fileConfig'=>$options['fileConfig'],
													 'section'=>'validators',
													));
	}
	public function addValidators($elementName,$options = null){
		if(!empty($elementName)){
			$config = $this->_configFile->getConfig($elementName);
			
			foreach ($config as $key =>$val){
				$validateClass = "Zend_Validate_" . $key;				
				$class = $validateClass($val['option']);
				$validatorObj = $this->_validatorObj;
				$validatorObj->addValidator(new $class,$val['breakChainOnFailure']);
			}
			
		}
		return $validatorObj;
	}
}